﻿@{
    ViewBag.Title = "Địa bàn - hộ dân cư";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
    string strMaDiaBanGlobal = Request["strMaDiaBanGlobal"];
}

<script type="text/javascript" src="http://viettelmap.vn/VTMapService/VTMapAPI?api=VTMap&type=main&k=dffc8675fc5d781ea8f0131f7d855565"></script>

@Scripts.Render("~/Scripts/qlyHoTheoTienDo.js")
<script src="~/Scripts/Airview-master/vendor/tooltip.min.js"></script>
<script src="~/Scripts/Airview-master/airview.min.js"></script>
@Styles.Render("~/Content/styleMap_navbar.css")

<script>
    @functions{
        public string GetAntiForgeryToken()
        {
            string cookieToken, formToken;
            AntiForgery.GetTokens(null, out cookieToken, out formToken);
            return cookieToken + "," + formToken;
        }
    }
    var pwidth = 1380;
    var pheight = pwidth * 0.7;
    var strUrlGetAreaCode = '@Url.Action("GetAreaBoundPointByAreaCode", "Area")';
    var strUrlGetAllHouseID = '@Url.Action("GetAllHouseID", "Area")';
    var headers = {};
    var strMaDiaBanPrint = null;
    var soho = 0;
    var j = 1;

    $(document).ready(function () {
        $('#map').width(pwidth);
        $('#map').height(pheight);
        headers['VerificationToken'] = '@GetAntiForgeryToken()';
        var serviceUrl = null;
        var strCommuneCode = null;
        strMaDiaBanPrint = '@strMaDiaBanGlobal';

        serviceUrl = '@ViewBag.ServiceUrl';
        strCommuneCode = '@ViewBag.CommuneCode';
        loadMapToDraw("1", serviceUrl, strCommuneCode, "1", strMaDiaBanPrint);

        if ('@strMaDiaBanGlobal' != "") {
            var jsonResultPoint;
            $.ajax({
                //url: '/Area/GetAllHouseID',
                url: strUrlGetAllHouseID,
                headers: headers,
                contentType: "application/json; charset=utf-8",
                type: "GET",
                dataType: "json",
                data: { 'AREA_CODE': strMaDiaBanPrint },
                async: false,
                responseType: "json",
                success: function (respone) {
                    jsonResultPoint = respone;
                },
                error: function (xhr) {
                    alert('Không kết nối được đến DataBase 242!');
                    return null;
                },
                complete: function (jqXHR, textStatus) {
                    //Xu ly ve bookmark o day
                    for (var i = 0; i < jsonResultPoint.length; i++) {
                        //xac dinh mau tuong ung cua khu vuc hanh chinh dua vao tong dan so tuong ung
                        if (jsonResultPoint[i].SURVEY_METHOD_ID == "02" || jsonResultPoint[i].SURVEY_METHOD_ID == "03") {
                            j += 1;
                        }
                    }
                    soho = j;
                }
            });
        }

        $('#printMap').click(function () {
            var divPrint = $('#divMapPrint');
            divPrint.html('<iframe src="@Url.Action("getPrint")?strMaDiaBanPrint=' + strMaDiaBanPrint + '&Strsoho=' + soho + '" style="display:none;"></iframe>');
            return false;
        });

        $('#printClose').click(function () {
            parent.$('body').css('overflow', 'scroll');
            parent.$('#divPrintMapA3').remove();
            return false;
        });
    });

    var getContentMap = function () {
        //var map = $('.mapcontent .olMapViewport');
        var map = $('.map_content .olMapViewport');
        return { width: pwidth, html: map.html() };
    };

</script>
<div class="full-height-content">
    <div class="full-height-content-body" style="overflow:hidden;">
        <div id='map' class="map_content"></div>
        <div id='divMapPrint'></div>

        <div class="Row" style="max-width: 180px; position: absolute; clear: left; z-index: 1000; ">
            <div class="col-lg-7">
                <button id="printMap" style="width:100px" type="button" class="btn btn-sm btn-default btn_search_household">
                    <i class="fa fa-print"></i> In bản đồ
                </button>
            </div>
            <div class="col-lg-5">
                <button id="printClose" style="width: 70px" type="button" class="btn btn-sm btn-default btn_search_household">
                    <i class="fa fa-times"></i> Đóng
                </button>
            </div>

        </div>
    </div>
</div>
